package org.hawk.gwt.ppc.scanner.mock;

import java.lang.reflect.Method;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.RootPanel;

/**
 * @author alex.bereznevatiy@gmail.com
 */
public class Mock3 {
	private Button alertMeButton;

	public void onModuleLoad() {
		final RootPanel rootPanel = RootPanel.get();

		alertMeButton = new Button();
		rootPanel.add(alertMeButton);
		alertMeButton.setText("Alert me!");
		alertMeButton.addClickHandler(new ClickHandler(){
			public void onClick(ClickEvent event) {
				try {
					Class<?> cls = Class.forName(
						"org.hawk.gwt.ppc.examples.methods.MethodsSource");
					Method m = cls.getMethod("alertMe", String.class);
					m.invoke(null, "This is alert text");
				}
				catch(Exception ex){
					GWT.log("Error!",ex);
				}
			}
		});
	}
}
